﻿using System.Collections.Generic;
using UnityEngine;

[UIAssetInfo("game/uiframework.bundle", "UIRoot")]
public sealed class UIRoot : UIBase
{
    [SerializeField]
    private RectTransform Layers = null;
    [SerializeField]
    private Camera Camera = null;
    [SerializeField]
    private RectTransform TopLayers = null;
    [SerializeField]
    private Camera TopCamera = null;

    private Dictionary<EWindowLayer, Transform> windowRoot = new Dictionary<EWindowLayer, Transform>(8);

    private void Awake()
    {
        DontDestroyOnLoad(this);
        foreach(EWindowLayer v in System.Enum.GetValues(typeof(EWindowLayer))) {
            RectTransform topRoot = v <= EWindowLayer.WINDOWS ? Layers : TopLayers;
            GameObject obj = new GameObject(v.ToString());
            obj.transform.SetParent(topRoot, false);
            // obj.transform.localScale = Vector3.one;
            windowRoot.Add(v, obj.transform);
        }
    }

    public Transform GetWindowParent(EWindowLayer layer)
    {
        return windowRoot[layer];
    }
}
